<?php

namespace App\Http\Controllers\Admin;

use App\Models\Comment;
use App\Models\Post;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class CommentController extends Controller
{
    public function index() {

        $comments = Comment::orderBy('id','desc')->paginate(10);
        $comments->load('user');
        $arr_ids = $comments->pluck('post_id');
        $titles = Post::whereIn('id',$arr_ids)->get(['id','title']);
        $is_null = true;
        return view('admin.comment.index',compact('comments','titles','is_null'));
    }
}
